package com.agileboot.domain.system.dict.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.system.dict.db.SysDictTypeEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class DictTypeQuery extends AbstractPageQuery<SysDictTypeEntity> {

    protected String dictName;

    protected String dictType;

    protected Integer status;

    @Override
    public QueryWrapper<SysDictTypeEntity> addQueryCondition() {
        QueryWrapper<SysDictTypeEntity> queryWrapper = new QueryWrapper<SysDictTypeEntity>();

        queryWrapper.eq(StrUtil.isNotEmpty(dictName), "dict_name", dictName)
                .eq(status != null, "status", status) // 判断 status 是否不为 null
                .eq(StrUtil.isNotEmpty(dictType), "dict_name", dictType);

        this.timeRangeColumn = "createTime";
        // 设置排序字段
        this.orderColumn="update_time";
        this.orderDirection="descending";

        return queryWrapper;
    }

}
